﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using GameSchoolWeb.Models;
using GameSchoolWeb.Controllers;
using GameSchoolWeb.Tests;
using Moq;
using System.Web.Mvc;

/// <summary>
/// MockCourseRepository býr til gervigögn fyrir prófanir á föllum í verkefninu.
/// Classinn erfir InterfaceUserRepository og útfærir þau föll sem þörf er á fyrir 
/// einingarprófanir. Föll sem ekki eru notuð eru ekki útfærð.
/// Því miður var ekki nægur tími til að ná virkni fyrir Guid(unique identifier) fyrir einingar prófanir.
///</summary>
namespace GameSchoolWeb.Tests.Controllers
{
    class MockUserRepository : IUserRepository
    {
        List<aspnet_User> m_Users = new List<aspnet_User>();
        List<aspnet_UsersInRole> m_UsersInRole = new List<aspnet_UsersInRole>();
        List<aspnet_Role> m_Role = new List<aspnet_Role>();

        //Constructor
        public MockUserRepository()
        {
            GetUsers();
        }
        
        // Býr til tilvik af notendum fyrir kerfið
        public List<aspnet_User> GetUsers()
        {
            Guid here = new Guid();
            m_Users.Add ( new aspnet_User { UserId = here, UserName = "Alexander Pattason", IsAnonymous = false, LastActivityDate = DateTime.Parse("2002-09-01") } );

            Guid here2 = new Guid();
            m_Users.Add ( new aspnet_User { UserId = here2, UserName = "Halli Snillingurson", IsAnonymous = false, LastActivityDate = DateTime.Parse("2002-09-01") });

            Guid here3 = new Guid();
            m_Users.Add ( new aspnet_User { UserId = here3, UserName = "Bubbi Byggirson", IsAnonymous = false, LastActivityDate = DateTime.Parse("2002-09-01") });

            Guid here4 = new Guid();
            m_Users.Add(new aspnet_User { UserId = here4, UserName = "Óli Nubbisson", IsAnonymous = false, LastActivityDate = DateTime.Parse("2002-09-01") });

            Guid here5 = new Guid();
            m_Users.Add(new aspnet_User { UserId = here5, UserName = "Heimir Tanksson", IsAnonymous = false, LastActivityDate = DateTime.Parse("2002-09-01") });

            Guid here6 = new Guid();
            m_Users.Add(new aspnet_User { UserId = here6, UserName = "Sindri Greenson", IsAnonymous = false, LastActivityDate = DateTime.Parse("2002-09-01") });


            return m_Users;
        }

        // Bætir við notendum í samræmi við virkni í GameSchoolDB.dbml
        void addUser(aspnet_User NewUser)
        {
            m_Users.Add(NewUser);
        }

        public IQueryable<aspnet_User> Users()
        {
            return m_Users.AsQueryable();
        }

        void addUserInRole(aspnet_UsersInRole newUserInRole)
        {
            m_UsersInRole.Add(newUserInRole);
        }

        public IQueryable<aspnet_UsersInRole> UsersInRole()
        {
            Guid UserIdent = new Guid();
            Guid Roleident = new Guid();
            m_UsersInRole.Add(new aspnet_UsersInRole { UserId = UserIdent, RoleId = Roleident });

            return m_UsersInRole.AsQueryable();
        }

        public IQueryable<aspnet_Role> Role()
        {
            throw new NotImplementedException();

        }
    }
}
